home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 201-225 / disk_204 / jpclock / jpclock.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  16KB  |  455 lines

  1. /* JPClock - © Copyright 1989 by Jonathan Potter
  2.  
  3.    This is my first, fully functional program written under Lattice C v5.02
  4.  
  5.    Anyone ever tried converting Manx code to Lattice? yuk... */
  6.  
  7. /* This program is Public Domain; do with it what you will, but if you choose
  8.  
  9.    to sell it, at least leave my name in it. */
  10.  
  11. #include <stdio.h>
  12. #include <ctype.h>
  13. #include <stdlib.h>
  14. #include <exec/types.h>
  15. #include <intuition/intuitionbase.h>
  16. #include <exec/memory.h>
  17. #include <libraries/dos.h>
  18. #include <libraries/dosextens.h>
  19. #include <devices/audio.h>
  20. #include <devices/timer.h>
  21. #include <exec/tasks.h>
  22. #include <proto/all.h>
  23. #include <pragma/all.h>
  24. #include <string.h>
  25. #include <dos.h>
  26. #include "JPClock.i"
  27.  
  28. /* lsr info */
  29. long _stack=4000;
  30. char *_procname="JPClock";
  31. long _priority=0;
  32. long _BackGroundIO=1;
  33. extern BPTR _Backstdout;
  34.  
  35. /* gadget ids */
  36. #define SWAPSCREENS 1
  37. #define STAYFRONT 2
  38. #define ALARM 3
  39. #define TIME 4
  40. #define ALARMTIME 5
  41. #define DATE 6
  42.  
  43. char TextBuffer[56];
  44. char TimeBuffer[9], DateBuffer[9], AlarmBuffer[9]="00:00:00";
  45.  
  46. /* the font we'll use if default > 8 point */
  47. struct TextAttr TopazText={
  48.     "topaz.font",8,0,0};
  49.  
  50. /* where all the text goes */
  51. struct IntuiText TextPrint={
  52.     1,0,JAM2,0,0,NULL,TextBuffer,NULL};
  53.  
  54. short SXYBorder[]={
  55.     -1,-1,72,-1,72,8,-1,8,-1,-1};
  56. struct Border SBorder={
  57.     0,0,3,0,JAM1,5,SXYBorder,NULL};
  58.  
  59. struct StringInfo TimeStringInfo={
  60.     TimeBuffer,NULL,0,9,0};
  61. struct StringInfo DateStringInfo={
  62.     DateBuffer,NULL,0,9,0};
  63. struct StringInfo AlarmStringInfo={
  64.     AlarmBuffer,NULL,0,9,0};
  65. struct IntuiText TimeStringText={
  66.     1,0,JAM2,-35,0,NULL,(UBYTE *)"TIME",NULL};
  67. struct IntuiText AlarmStringText={
  68.     1,0,JAM2,-43,0,NULL,(UBYTE *)"ALARM",NULL};
  69. struct IntuiText DateStringText={
  70.     1,0,JAM2,-35,0,NULL,(UBYTE *)"DATE",NULL};
  71. struct Gadget TimeStringGadget={
  72.     NULL,123,15,72,8,GADGHCOMP,TOGGLESELECT|RELVERIFY,STRGADGET,
  73.     (APTR)&SBorder,NULL,&TimeStringText,NULL,(APTR)&TimeStringInfo,TIME,NULL};
  74. struct Gadget DateStringGadget={
  75.     &TimeStringGadget,238,15,72,8,GADGHCOMP,TOGGLESELECT|RELVERIFY,STRGADGET,
  76.     (APTR)&SBorder,NULL,&DateStringText,NULL,(APTR)&DateStringInfo,DATE,NULL};
  77. struct Gadget AlarmStringGadget={
  78.     &DateStringGadget,361,15,72,8,GADGHCOMP,TOGGLESELECT|RELVERIFY,STRGADGET,
  79.     (APTR)&SBorder,NULL,&AlarmStringText,NULL,(APTR)&AlarmStringInfo,ALARMTIME,NULL};
  80.  
  81. short GXYBorder[]={
  82.     -1,-1,100,-1,100,11,-1,11,-1,-1};
  83. struct Border GBorder={
  84.     0,0,3,0,JAM1,5,GXYBorder,NULL};
  85. struct IntuiText AlarmText={
  86.     1,0,JAM2,14,2,NULL,(UBYTE *)"Alarm On",NULL};
  87. struct Gadget AlarmGadget={
  88.     &AlarmStringGadget,325,30,100,11,GADGHCOMP,RELVERIFY|TOGGLESELECT,BOOLGADGET,
  89.     (APTR)&GBorder,NULL,&AlarmText,
  90.     NULL,NULL,ALARM,NULL};
  91. struct IntuiText StayFrontText={
  92.     1,0,JAM2,10,2,NULL,(UBYTE *)"Stay Front",NULL};
  93. struct Gadget StayFrontGadget={
  94.     &AlarmGadget,215,30,100,11,GADGHCOMP,RELVERIFY|TOGGLESELECT,BOOLGADGET,
  95.     (APTR)&GBorder,NULL,&StayFrontText,
  96.     NULL,NULL,STAYFRONT,NULL};
  97. struct IntuiText SwapScreensText={
  98.     1,0,JAM2,2,2,NULL,(UBYTE *)"Swap Screens",NULL};
  99. struct Gadget SwapScreensGadget={
  100.     &StayFrontGadget,105,30,100,11,GADGHCOMP,RELVERIFY,BOOLGADGET,
  101.     (APTR)&GBorder,NULL,&SwapScreensText,
  102.     NULL,NULL,SWAPSCREENS,NULL};
  103.  
  104. struct NewWindow ClockWindow={
  105.     86,0,504,10,-1,-1,CLOSEWINDOW|MOUSEBUTTONS|NEWSIZE|GADGETUP|INACTIVEWINDOW,
  106.     WINDOWCLOSE|WINDOWDEPTH|WINDOWDRAG|SMART_REFRESH|NOCAREREFRESH|RMBTRAP,
  107.     &SwapScreensGadget,NULL,"",NULL,NULL,0,0,0,110,CUSTOMSCREEN};
  108.  
  109. struct IntuitionBase *IntuitionBase;
  110. struct IntuiMessage *Msg;
  111. struct Window *Window;
  112. struct timerequest TimeReq;
  113. struct MsgPort *TimerPort;
  114.  
  115. void main(argc,argv)
  116. int argc;
  117. char *argv[];
  118. {
  119.     /* heaps of variables, aren't there ? */
  120.     register short Chip, Fast, Total;
  121.     int dy, mn, yr, sizeflag=0, GadgetID, ScreenHeight, ScreenWidth, delay=1, al,
  122.         StayFront=0, Alarm=0, a, b, c, USA=0, Swap=0, j, x, y, AlarmSet=0, AE,
  123.         DTime=1, DDay=1, DDate=1, DFast=1, DChip=1, DTotal=1, TwelveHour=0, message;
  124.     char d[8], Date[9], Time[9], buf[15], ch;
  125.     char *Day[7]={ "Sun","Mon","Tue","Wed","Thu","Fri","Sat" };
  126.     struct Gadget *Gad;
  127.     struct Screen *NextScreen;
  128.  
  129.     /* was I run from CLI? */
  130.     if (_Backstdout) {
  131.     /* yup */
  132.         if ((strncmp(argv[1],"?",1))==0) {
  133.             /* need some help */
  134.             Write(_Backstdout,"\n",-1);
  135.             Write(_Backstdout,"\x9B;0;1;2mJPClock\x9B;0;1m © Copyright 1989 by \x9B;0;1;33;4mJonathan Potter\x9B;0;1m (08-293-2788)\x9B;0m\n",-1);
  136.             Write(_Backstdout,"\n\x9B;0;33mThe ultimate Workbench clock!\x9B;0m\n\n",-1);
  137.             Write(_Backstdout,"Usage : JPClock [FLAGS]\n\nFlags are:\n\n",-1);
  138.             Write(_Backstdout,"        -a           : Set Alarm on\n",-1);
  139.             Write(_Backstdout,"        -atALARMTIME : Set Alarm time to ALARMTIME (HH:MM:SS or H:MM:SSC)\n",-1);
  140.             Write(_Backstdout,"        -dSECONDS    : Set Delay between updates to SECONDS seconds\n",-1);
  141.             Write(_Backstdout,"        -f           : Set Stay Front on\n",-1);
  142.             Write(_Backstdout,"        -ot          : Turn time display off\n",-1);
  143.             Write(_Backstdout,"        -oy          : Turn day display off\n",-1);
  144.             Write(_Backstdout,"        -od          : Turn date display off\n",-1);
  145.             Write(_Backstdout,"        -of          : Turn fast memory display off\n",-1);
  146.             Write(_Backstdout,"        -oc          : Turn chip memory display off\n",-1);
  147.             Write(_Backstdout,"        -ol          : Turn total memory display off\n",-1);
  148.             Write(_Backstdout,"        -s           : Swap to second screen\n",-1);
  149.             Write(_Backstdout,"        -u           : USA format; MM-DD-YY instead of DD-MM-YY\n",-1);
  150.             Write(_Backstdout,"        -xX          : Open window with x-coordinate X\n",-1);
  151.             Write(_Backstdout,"        -yY          : Open window with y-coordinate Y\n",-1);
  152.             Write(_Backstdout,"        -12          : Set time to 12 hours format\n",-1);
  153.             /* close our output channel */
  154.             Close(_Backstdout);
  155.             /* and get outahere */
  156.             exit(0);
  157.         }
  158.  
  159.         /* close output channel.. if we don't, the cli window can never close */
  160.         Close(_Backstdout);
  161.         /* let's 'ave a bo peep at our args then */
  162.         for (dy=1;dy<argc;dy++) {
  163.             /* delay */
  164.             if ((strncmp(argv[dy],"-d",2))==0)
  165.                 if ((sscanf(argv[dy],"-d%d",&delay))<1 || delay<0) delay=1;
  166.             /* stay front */
  167.             if ((strncmp(argv[dy],"-f",2))==0) {
  168.                 StayFront=1;
  169.                 StayFrontGadget.Flags=GADGHCOMP|SELECTED;
  170.             }
  171.             /* alarm */
  172.             if ((strncmp(argv[dy],"-a",2))==0) {
  173.                 Alarm=1;
  174.                 AlarmGadget.Flags=GADGHCOMP|SELECTED;
  175.             }
  176.             /* set alarm time */
  177.             if ((strncmp(argv[dy],"-at",3))==0) {
  178.                 AlarmSet=1; AE=dy;
  179.             }
  180.             if ((strncmp(argv[dy],"-ot",3))==0) DTime=0; /* time off */
  181.             if ((strncmp(argv[dy],"-oy",3))==0) DDay=0; /* day off */
  182.             if ((strncmp(argv[dy],"-od",3))==0) DDate=0; /* date off */
  183.             if ((strncmp(argv[dy],"-of",3))==0) DFast=0; /* fast mem off */
  184.             if ((strncmp(argv[dy],"-oc",3))==0) DChip=0; /* chip mem off */
  185.             if ((strncmp(argv[dy],"-ol",3))==0) DTotal=0; /* total mem off */
  186.             if ((strncmp(argv[dy],"-u",2))==0) USA=1; /* usa backwards dates */
  187.             if ((strncmp(argv[dy],"-s",2))==0) Swap=1; /* auto go to 2nd screen */
  188.             /* new x position */
  189.             if ((strncmp(argv[dy],"-x",2))==0) {
  190.                 sscanf(argv[dy],"-x%d",&x);
  191.                 if (x<0) x=0;
  192.                 ClockWindow.LeftEdge=x;
  193.             }
  194.             /* new y position */
  195.             if ((strncmp(argv[dy],"-y",2))==0) {
  196.                 sscanf(argv[dy],"-y%d",&y);
  197.                 if (y<0) y=0;
  198.                 ClockWindow.TopEdge=y;
  199.             }
  200.             /* 12 hour time */
  201.             if ((strncmp(argv[dy],"-12",3))==0) {
  202.                 TwelveHour=1;
  203.                 sprintf(AlarmBuffer,"0:00:00A");
  204.             }
  205.         }
  206.     }
  207.     if (delay>10) delay=10; delay*=1000000;
  208.     /* can't have no display; if asked for, at least show time */
  209.     if (DTime==0 && DDay==0 && DDate==0 && DFast==0 && DChip==0 && DTotal==0) DTime=1;
  210.     if (DTime) { sprintf(buf,"         "); strcat(TextBuffer,buf); }
  211.     if (DDay) { sprintf(buf,"    "); strcat(TextBuffer,buf); }
  212.     if (DDate) { sprintf(buf,"         "); strcat(TextBuffer,buf); }
  213.     if (DFast) { sprintf(buf,"          "); strcat(TextBuffer,buf); }
  214.     if (DChip) { sprintf(buf,"          "); strcat(TextBuffer,buf); }
  215.     if (DTotal) { sprintf(buf,"           "); strcat(TextBuffer,buf); }
  216.     /* now what was that alarm time ? */
  217.     if (AlarmSet) {
  218.         a=0; b=0; c=0;
  219.         if (TwelveHour) {
  220.             sscanf(argv[AE],"-at%d:%d:%d%c",&a,&b,&c,&ch);
  221.             sprintf(AlarmBuffer,"%1d:%02d:%02d%1c",a,b,c,toupper(ch));
  222.         }
  223.         else {
  224.             sscanf(argv[AE],"-at%d:%d:%d",&a,&b,&c);
  225.             sprintf(AlarmBuffer,"%02d:%02d:%02d",a,b,c);
  226.         }
  227.     }
  228.     /* find out how wide window needs to be */
  229.     ClockWindow.Width=(strlen(TextBuffer)*8)+80;
  230.     if (ClockWindow.LeftEdge>640-ClockWindow.Width) ClockWindow.LeftEdge=640-ClockWindow.Width;
  231.     IntuitionBase=(struct IntuitionBase *) OpenLibrary("intuition.library",0);
  232.     ClockWindow.Screen=(struct Screen *) IntuitionBase->FirstScreen;
  233.     if (ClockWindow.TopEdge>(ClockWindow.Screen->Height-10)) ClockWindow.TopEdge=ClockWindow.Screen->Height-10;
  234.     if ((Window=(struct Window *) OpenWindow(&ClockWindow))==NULL) goto bye;
  235.     /* if default font is too big, use topaz 8 */
  236.     if (Window->IFont->tf_YSize>8)
  237.         TextPrint.ITextFont=&TopazText;
  238.     if ((TimerPort=CreatePort("Timer Port",0))==NULL) goto bye;
  239.     if (OpenDevice(TIMERNAME,UNIT_VBLANK,&TimeReq,0)!=NULL) goto bye;
  240.     /* set up timer device request */
  241.     TimeReq.tr_node.io_Message.mn_ReplyPort=TimerPort;
  242.     TimeReq.tr_node.io_Command=TR_ADDREQUEST;
  243.     TimeReq.tr_node.io_Flags=0;
  244.     TimeReq.tr_node.io_Error=0;
  245.     TimeReq.tr_time.tv_secs=0;
  246.     TimeReq.tr_time.tv_micro=delay;
  247.     SendIO((char *) &TimeReq.tr_node);
  248.     /* lets go to next screen */
  249.     if (Swap==1) {
  250.         NextScreen=(struct Screen *) Window->WScreen->NextScreen;
  251.         if (NextScreen==NULL || NextScreen->Width<ClockWindow.Width ||
  252.             NextScreen->Height<45)
  253.             NextScreen=(struct Screen *) Window->WScreen;
  254.         ClockWindow.Screen=NextScreen;
  255.         CloseWindow(Window);
  256.         Window=(struct Window *) OpenWindow(&ClockWindow);
  257.         ScreenToFront(NextScreen);
  258.     }
  259.     /* de main loop */
  260.     FOREVER {
  261.         loop:
  262.         if (StayFront==1) WindowToFront(Window); /* shove to front if asked for */
  263.         Chip=AvailMem(MEMF_CHIP)>>10; /* combien memory? */
  264.         Fast=AvailMem(MEMF_FAST)>>10;
  265.         Total=Chip+Fast;
  266.         getclk(d); /* neat lattice function */
  267.         stpdate(Date,3,&d[1]);
  268.         stptime(Time,2,&d[4]);
  269.         sscanf(Date,"%d-%d-%d",&mn,&dy,&yr);
  270.         if (USA==0) sprintf(Date,"%02d-%02d-%02d",dy,mn,yr); /* backwards :-) */
  271.         else sprintf(Date,"%02d-%02d-%02d",mn,dy,yr);
  272.         if (TwelveHour) {
  273.             ch='A'; j=d[4]; if (j>12) { j=j-12; ch='P'; }
  274.             sprintf(Time,"%1d:%02d:%02d%1c",j,d[5],d[6],ch);
  275.         }
  276.         sprintf(buf,""); /* clear both buffers */
  277.         sprintf(TextBuffer,"");
  278.         if (DTime) { sprintf(buf," %s",Time); strcat(TextBuffer,buf); }
  279.         if (DDay) { sprintf(buf," %s",Day[(int)d[0]]); strcat(TextBuffer,buf); }
  280.         if (DDate) { sprintf(buf," %s",Date); strcat(TextBuffer,buf); }
  281.         if (DFast) { sprintf(buf," FAST:%-4d",Fast); strcat(TextBuffer,buf); }
  282.         if (DChip) { sprintf(buf," CHIP:%-4d",Chip); strcat(TextBuffer,buf); }
  283.         if (DTotal) { sprintf(buf," TOTAL:%-4d",Total); strcat(TextBuffer,buf); }
  284.         /* print it out! */
  285.         PrintIText(Window->RPort,&TextPrint,28,1);
  286.         /* check for alarm if asked */
  287.         if (Alarm==1) {
  288.             if ((strncmp(Time,AlarmBuffer,8))==0) { /* alarm time! */
  289.                 for (al=0;al<10;al++) {
  290.                     DisplayBeep(NULL);
  291.                     Delay(1);
  292.                 }
  293.             }
  294.         }
  295.         /* got an intuimessage */
  296.         if (Msg=(struct IntuiMessage *) GetMsg(Window->UserPort)) goto gotone;
  297.         /* wait for a message */
  298.         message=Wait (1<<Window->UserPort->mp_SigBit | 1<<TimerPort->mp_SigBit);
  299.         /* timer message? */
  300.         if (message&1<<TimerPort->mp_SigBit) {
  301.             (void) GetMsg(TimerPort);
  302.             TimeReq.tr_time.tv_secs=0;
  303.             TimeReq.tr_time.tv_micro=delay;
  304.             SendIO(&TimeReq.tr_node);
  305.             goto loop;
  306.         }
  307.         /* nup, it was intui */
  308.         Msg=(struct IntuiMessage *) GetMsg(Window->UserPort);
  309.         gotone:
  310.         ReplyMsg((struct Message *)Msg);
  311.         switch (Msg->Class) {
  312.             case CLOSEWINDOW: /* bye de bye */
  313.                 goto bye;
  314.                 break;
  315.  
  316.             case MOUSEBUTTONS:
  317.                 if (Msg->Code!=MENUDOWN) break;
  318.                 /* hit de right mouse button; resize */
  319.                 if (sizeflag==0) {
  320.                     /* make it big */
  321.                     ScreenHeight=Window->WScreen->Height;
  322.                     ScreenWidth=Window->WScreen->Width;
  323.                     if (Window->TopEdge+45>ScreenHeight)
  324.                         MoveWindow(Window,0,-((Window->TopEdge)-(ScreenHeight-45)));
  325.                     if (Window->LeftEdge+504>ScreenWidth)
  326.                         MoveWindow(Window,-((Window->LeftEdge)-(ScreenWidth-504)),0);
  327.                     SizeWindow(Window,(504-ClockWindow.Width),35);
  328.                     sizeflag=1;
  329.                     WaitForNewSize(); /* stupid how you have to do this */
  330.                     break;
  331.                 }
  332.                 else {
  333.                     /* make it small */
  334.                     SizeWindow(Window,-(504-ClockWindow.Width),-35);
  335.                     sizeflag=0;
  336.                     WaitForNewSize();
  337.                 }
  338.                 break;
  339.  
  340.             case GADGETUP:
  341.                 /* a gadget! */
  342.                 Gad=(struct Gadget *) Msg->IAddress;
  343.                 GadgetID=Gad->GadgetID;
  344.                 switch (GadgetID) {
  345.                     case SWAPSCREENS: /* go to next screen */
  346.                         NextScreen=(struct Screen *) Window->WScreen->NextScreen;
  347.                         /* if next screen can't fit us, don't */
  348.                         if (NextScreen==NULL || NextScreen->Width<ClockWindow.Width ||
  349.                             NextScreen->Height<45)
  350.                             NextScreen=(struct Screen *) Window->WScreen;
  351.                         ClockWindow.Screen=NextScreen;
  352.                         CloseWindow(Window);
  353.                         Window=(struct Window *) OpenWindow(&ClockWindow);
  354.                         ScreenToFront(NextScreen); /* and bring new screen to front */
  355.                         sizeflag=0;
  356.                         break;
  357.  
  358.                     case STAYFRONT:
  359.                         /* toggle */
  360.                         if (StayFront==0) StayFront=1; else StayFront=0;
  361.                         break;
  362.  
  363.                     case ALARM:
  364.                         /* toggle */
  365.                         if (Alarm==0) Alarm=1; else Alarm=0;
  366.                         break;
  367.  
  368.                     case TIME:
  369.                         /* set the new time */
  370.                         a=0; b=0; c=0;
  371.                         if ((sscanf(TimeBuffer,"%d:%d:%d",&a,&b,&c))!=3 &&
  372.                                 (sscanf(TimeBuffer,"%d:%d",&a,&b))!=2 &&
  373.                                 (sscanf(TimeBuffer,"%d",&a))!=1) {
  374.                             /* didn't work; not entered properly */
  375.                             sprintf(TimeBuffer,"");
  376.                             RefreshGadgets(&TimeStringGadget,Window,NULL);
  377.                             break;
  378.                         }
  379.                         sprintf(TimeBuffer,"");
  380.                         RefreshGadgets(&TimeStringGadget,Window,NULL);
  381.                         d[4]=a; d[5]=b; d[6]=c;
  382.                         chgclk(d); /* another nifty lattice thingo */
  383.                         break;
  384.  
  385.                     case DATE:
  386.                         /* new date */
  387.                         if (USA==0) { a=d[3]; b=d[2]; c=d[1]+80; }
  388.                         else { a=d[2]; b=d[3]; c=d[1]+80; }
  389.                         if ((sscanf(DateBuffer,"%d-%d-%d",&a,&b,&c))!=3 &&
  390.                                 (sscanf(DateBuffer,"%d-%d",&a,&b))!=2 &&
  391.                                 (sscanf(DateBuffer,"%d",&a))!=1) {
  392.                             sprintf(DateBuffer,"");
  393.                             RefreshGadgets(&DateStringGadget,Window,NULL);
  394.                             break;
  395.                         }
  396.                         sprintf(DateBuffer,"");
  397.                         RefreshGadgets(&DateStringGadget,Window,NULL);
  398.                         if (c<80) break;
  399.                         if (USA==0)    { d[1]=c-80; d[2]=b; d[3]=a; }
  400.                         else { d[1]=c-80; d[2]=a; d[3]=b; }
  401.                         chgclk(d);
  402.                         break;
  403.  
  404.                     case ALARMTIME:
  405.                         /* new al. time */
  406.                         a=0; b=0; c=0;
  407.                         if (TwelveHour) {
  408.                             sscanf(AlarmBuffer,"%d:%d:%d%c",&a,&b,&c,&ch);
  409.                             ch=toupper(ch);
  410.                             sprintf(AlarmBuffer,"%1d:%02d:%02d%1c",a,b,c,ch);
  411.                         }
  412.                         else {
  413.                             sscanf(AlarmBuffer,"%d:%d:%d",&a,&b,&c);
  414.                             sprintf(AlarmBuffer,"%02d:%02d:%02d",a,b,c);
  415.                         }
  416.                         RefreshGadgets(&AlarmStringGadget,Window,NULL);
  417.                         break;
  418.  
  419.                     default:
  420.                         break;
  421.                 }
  422.                 break;
  423.  
  424.             default:
  425.                 break;
  426.         }
  427.     }
  428.     bye:
  429.     /* outahere! */
  430.     if (TimeReq.tr_node.io_Message.mn_ReplyPort) CloseDevice(&TimeReq);
  431.     if (TimerPort) DeletePort(TimerPort);
  432.     if (Window) CloseWindow(Window);
  433.     if (IntuitionBase) CloseLibrary((struct Library *) IntuitionBase);
  434.     OpenWorkBench(); /* don't see how it could be closed, but.. */
  435.     exit(0);
  436. }
  437.  
  438. WaitForNewSize()
  439. {
  440.     while (TRUE) {
  441.         WaitPort(Window->UserPort);
  442.         Msg=(struct IntuiMessage *) GetMsg(Window->UserPort);
  443.         if (Msg->Class==INACTIVEWINDOW) {
  444.             ReplyMsg((struct Message *) Msg);
  445.             return(0);
  446.         }
  447.         if (Msg->Class!=NEWSIZE) {
  448.             ReplyMsg((struct Message *) Msg);
  449.             continue;
  450.         }
  451.         ReplyMsg((struct Message *) Msg);
  452.         break;
  453.     }
  454. }
  455.